// let Opt = {
//     bind: function (el, binding, vnode) {
//         console.log(el);
//         console.log(binding);
//         console.log(vnode);
//     },
//     inserted: function (el, binding, vnode) {},
//     update: function (el, binding, vnode) {},
//     componentUpdated: function (el, binding, vnode) {},
//     unbind: function (el, binding, vnode) {}
// };

// export default Opt;

export default {
    bind: function (el, binding, vnode) {
        console.log('el', el);
        console.log('biding', binding);

        // NOTE:这里有坑
        // 这个 binding.value 是来自于你自己给的指令的赋值里的对象的
        const options = binding.value;
        let { className, activeClass, selectedIndex } = options;
        console.log(options);
        // const { selectedIndex } = options;
    },
    update: function (el, binding, vnode) {
        const options = binding.value;
        const Old_options = binding.oldValue;

        let { selectedIndex: Old_selectedIndex } = Old_options;
        let { className, activeClass, selectedIndex } = options;

        if (Old_selectedIndex !== -1) el.children[Old_selectedIndex].classList.remove(className);
        el.children[selectedIndex].classList.add(className);
    }
};
